package com.key.controller.admin.assetManagement;

import com.key.common.R;
import com.key.common.dto.ReceiptAssetsDTO;
import com.key.common.dto.ReceiptDTO;
import com.key.common.dto.WithdrawalDTO;
import com.key.common.vo.AssetsTVO;
import com.key.entity.*;
import com.key.mapper.ReceiptAssetsMapper;
import com.key.service.ReceiptAssetsService;
import com.key.service.WithdrawalAssetsService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 *  @description:领用退库管理Controller
 * @author tc
 * @create 2023-02-17 10:42
 */
@Api(value = "领用与退库申请",tags = "领用与退库申请接口API")
@Controller
@RequestMapping(value ="/receiptAndWithdrawal" )
public class ReceiptAndWithdrawalController {

    @Autowired
    ReceiptAssetsService receiptAssetsService;
    @Autowired
    WithdrawalAssetsService withdrawalAssetsService;

    //已测试
    /**
     * 显示领用清单
     * @author tc
     */
    @ResponseBody
    @RequestMapping(value = "/findReceiptAssets",method = RequestMethod.POST)
    @ApiOperation(value = "领用清单表接口",notes = "领用单表的基本信息",httpMethod ="post")
    public R findReceiptAssets(@RequestBody @ApiParam(name = "receiptAssetsDTO",value = "查找时需要填入的属性",required = true) ReceiptDTO receiptDTO){
        return receiptAssetsService.findReceiptAssets(receiptDTO);
    }

    //已测试
    /**
     * 领用清单修改
     */
    @ResponseBody
    @RequestMapping(value = "/modifyReceiptAssetsByReceiptNumber",method = RequestMethod.POST)
    @ApiOperation(value = "领用单修改接口",notes = "对领用单进行修改",httpMethod = "post")
    public R modifyReceiptAssetsByReceiptNumber(@RequestBody @ApiParam(name = "receiptAssetsDTO",value = "修改时需要填入的属性",required = true) ReceiptDTO receiptDTO){
        return  receiptAssetsService.editReceiptAssets(receiptDTO);
    }

    //已测试
    /**
     * 领用清单删除
     */
    @ResponseBody
    @RequestMapping(value = "/deleteReceiptAssetsByReceiptNumber",method = RequestMethod.GET)
    @ApiOperation(value = "领用单删除接口",notes = "对借用单进行删除",httpMethod = "get")
    @ApiImplicitParam(name = "ReceiptNumber",value = "选中行的申请单号",paramType = "query",dataType = "String")
    public R deleteReceiptAssetsByReceiptNumber(@RequestParam(name = "ReceiptNumber") String ReceiptNumber){
        return receiptAssetsService.deleteReceiptAssets(ReceiptNumber);
    }

    //未测试
    /**
     * 领用清单详情
     */
    @ResponseBody
    @RequestMapping(value = "/showAllReceiptAssets",method = RequestMethod.GET)
    @ApiOperation(value = "领用申请单详情接口",notes = "展示领用单号的详细信息",httpMethod = "get")
    @ApiImplicitParam(name = "receiptNumber",value = "选中行的领用单号",paramType = "query",dataType = "String")
    public R showAllReceiptAssets(@RequestParam(name = "receiptNumber") String receiptNumber){
        R r=new R();
        ReceiptAssets receiptAssets=new ReceiptAssets();
        receiptAssets.setReceiptNumber(receiptNumber);
        List<AssetsTVO> resultList= receiptAssetsService.findAssetsTVOByReceiptAssets(receiptAssets);
        r.setData(resultList);
        return r;
    }

    /**
     * 显示退库清单
     * @author tc
     */
    @ResponseBody
    @RequestMapping(value = "/findWithdrawalAssets",method = RequestMethod.POST)
    @ApiOperation(value = "退库申请单详情接口",notes = "展示退库单号的详细信息",httpMethod = "post")
    public R showWithdrawalAssets(@RequestBody @ApiParam(name = "withdrawalDTO",value = "查找时需要填入的属性",required = true) WithdrawalDTO withdrawalDTO){
        return withdrawalAssetsService.findWithdrawalAssets(withdrawalDTO);
    }

    /**
     * 退库清单修改
     */
    @ResponseBody
    @RequestMapping(value = "/modifyWithdrawalAssetsByWithdrawalNumber",method = RequestMethod.POST)
    @ApiOperation(value = "退库请单修改接口",notes = "对退库单进行修改",httpMethod = "get")
    public R modifyWithdrawalAssetsByWithdrawalNumber(@RequestBody @ApiParam(name = "withdrawalDTO",value = "修改时需要填入的属性",required = true) WithdrawalDTO withdrawalDTO){
        return withdrawalAssetsService.editWithdrawalAssets(withdrawalDTO);
}

    /**
     * 退库清单删除
     */
    @ResponseBody
    @RequestMapping(value = "/deleteWithdrawalAssetsByWithdrawalNumber",method = RequestMethod.GET)
    @ApiOperation(value = "退库单删除接口",notes = "对退库单进行删除",httpMethod = "get")
    @ApiImplicitParam(name = "withdrawalNumber",value = "选中行的申请单号",paramType = "query",dataType = "String")
    public R deleteWithdrawalAssetsByWithdrawalNumber(@RequestParam(name = "withdrawalNumber") String withdrawalNumber){
        return  withdrawalAssetsService.deleteWithdrawalAssets(withdrawalNumber);
    }

    /**
     * 退库清单详情
     */
    @ResponseBody
    @RequestMapping(value = "/showAllWithdrawalAssets",method = RequestMethod.GET)
    @ApiOperation(value = "退库申请单详情接口",notes = "展示退库单号的详细信息",httpMethod = "get")
    @ApiImplicitParam(name = "withdrawalNumber",value = "选中行的退库单号",paramType = "query",dataType = "String")
    public R showAllWithdrawalAssets(@RequestParam(name = "withdrawalNumber") String WithdrawalNumber){
        R r=new R();
        WithdrawalAssets withdrawalAssets=new WithdrawalAssets();
        withdrawalAssets.setWithdrawalNumber(WithdrawalNumber);
        List<AssetsTVO> resultList= withdrawalAssetsService.findAssetsVTOByWithdrawalAssets(withdrawalAssets);
        r.setData(resultList);
        return r;
    }

}
